package com.design.boot.controller.door;

import com.design.boot.bean.ConfigBean;
import com.design.boot.bean.MyCat;
import com.design.boot.common.exception.VerificationCodeException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author kakayubei
 * @description
 * @date 2021/7/28 1:25
 */
@Controller
public class TestController {
    @Autowired
    private MyCat myCat;

    @Autowired
    private ConfigBean configBean;

    @RequestMapping("/config")
    @ResponseBody
    public String index() {
        return configBean.getName()+"——"+configBean.getAge();
    }

    @RequestMapping(value = "/cat", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public MyCat getCat() {
        return myCat;
    }

    @RequestMapping("/testException")
    @ResponseBody
    public String testException() throws VerificationCodeException {
        throw VerificationCodeException.throwVerificationCodeException();
    }

}
